package com.qiaofang.constant;

import com.qiaofang.common.utils.StringUtil;

public enum CustomerStatusEnum {

    report_invalid("a", "报备无效", null),
    visit_invalid("b", "到访无效", null),

    no_valid("-1", "无效", 4004),
    normal("0", "报备待审", null),
    has_visited("6", "已到访", 4003),
    not_visited("10", "未到访", 4002);

    private final String no;

    private final String des;

    private final Integer apiAction;

    CustomerStatusEnum(String no, String des, Integer apiAction) {
        this.no = no;
        this.des = des;
        this.apiAction = apiAction;
    }

    public String getNo() {
        return no;
    }

    public String getDes() {
        return des;
    }

    public Integer getApiAction() {
        return apiAction;
    }

    public static CustomerStatusEnum getByNo(String no) {
        if (StringUtil.isBlank(no)) {
            return null;
        }
        for (CustomerStatusEnum value : values()) {
            if (value.getNo().equals(no)) {
                return value;
            }
        }
        return null;
    }

    public static CustomerStatusEnum getByDesc(String desc) {
        if (StringUtil.isBlank(desc)) {
            return null;
        }
        for (CustomerStatusEnum value : values()) {
            if (value.getDes().equals(desc)) {
                return value;
            }
        }
        return null;
    }

    public static String getDescByNo(String no) {
        return getByNo(no) == null ? "" : getByNo(no).getDes();
    }

    /**
     * 状态要满足 到访 认筹 认购 签约
     *
     * @param status
     * @return
     */
    public static boolean checkStatus(String status) {
        String STATUS = "报备待审,未到访,已到访,无效";
        return StringUtil.contains(STATUS, status);
    }
}
